<?php

/*
 * This code is a sample showing how to use the
 * "server side" edtition of the sw6.xmlvalidator.
 * author: sw6b
 */


//Return codes from sw6.xmlvalidator
define("VALID_XML", 	0);
define("INVALID_XML", 	1);

//Commands to execute
$command 	= " ./exec.sh settings.xml";
$command	= escapeshellcmd($command);
$output 	= array();

//Execute command and store output and return value
exec($command, $output, $return);

if($return == VALID_XML) {
	//TODO: play a nice melody
	echo "settings.xml is valid";
} else {
	echo "settings.xml is invalid";
}

printSw6XmlValidatorOutput($output);

function printSw6XmlValidatorOutput($output) {
	foreach ($output as $value) {
		echo "<br/>\n".$value;
	}
}
?>
